package cn.edu.seig.springboot.service;

import cn.edu.seig.springboot.mapper.UserMapper;
import cn.edu.seig.springboot.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public User login(String username, String password, String role) {
        User user = userMapper.login(username, password, role);
        if (user != null) {
            // 登录成功后清除密码信息
            user.setPassword(null);
        }
        return user;
    }

    public User getUserById(Integer id) {
        return userMapper.getUserById(id);
    }
}
